﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Wolfy.Angularjs_Mvc_SPA.Models
{
    /// <summary>
    /// 集合单例，内存中存储数据
    /// </summary>
    public class ListDb<T> where T : class, new()
    {
        private static ListDb<T> _instance;
        private List<T> _lst;
        private static readonly object _lck = new object();

        public List<T> Lst { get => _lst; set => _lst = value; }

        private ListDb()
        {
            Lst = new List<T>();
        }
        public static ListDb<T> CreateList()
        {
            if (_instance == null)
            {
                lock (_lck)
                {
                    if (_instance == null)
                    {
                        _instance = new ListDb<T>();
                    }
                }
            }
            return _instance;
        }

    }
}